import { Row } from "antd";
import defaultData from "./data";
import Props from "../base/Props";
import { Fragment } from "react";
import OptionContent from "../../../../common/option-content";
import {WeaLocaleProvider} from "ecCom";

const getLabel = WeaLocaleProvider.getLabel;

export default class ComboxboxProps extends Props {
  _defV(options) {
    return options.filter(opt => opt.selected)
      .map(({ key }) => ({ key, value: '' }));
  }

  renderContent() {
    const { options } = this.props.data;

    return (
      <Fragment>
        <Row className='edc-sepline edc-row-hor'>
          <label>{getLabel('502499','选项内容')}</label>
          <OptionContent
            options={options}
            onChange={this.handlePropChange('options:(refs={"defaultValue": _defV})')}
          />
        </Row>
      </Fragment>
    )
  }
}

ComboxboxProps.defaultProps = {
  data: defaultData
};